package com.hkd.blogsystem.model;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.hkd.blogsystem.utils.DateUtils;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

@Data
public class BlogInfo {
    private Integer id;
    @NotBlank(message = "title不能为空")
    private String title;
    @NotBlank(message = "content 不能为空")
    private String content;
    private Integer userId;
    private Integer deleteFlag;

    //当前作者是否为登录用户
    private boolean isLoginUser;
    /**
     * Boolean 和 （boolean 会在json去掉is）
     */
    private Date createTime;


//    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    public String getUpdateTime() {
        if (updateTime == null){
            updateTime = new Date();
        }
        return DateUtils.format(updateTime);
    }
}
